package com.kfm.base.date;

import java.util.Calendar;

public class Demo02 {

    public static void main(String[] args) {
        Calendar calendar = Calendar.getInstance();

        System.out.println(calendar);

        System.out.println(calendar.getTimeInMillis());
        // Calendar --> Date
        System.out.println(calendar.getTime());

        // getField 2023-08-24 11:45:11:252 星期四
        System.out.println(calendar.get(1)); // 2023
        System.out.println(calendar.get(Calendar.YEAR)); // 2023
        System.out.println(calendar.get(Calendar.MONTH));// 7
        System.out.println(calendar.get(Calendar.DAY_OF_YEAR));// 236
        System.out.println(calendar.get(Calendar.DAY_OF_MONTH));// 24
        System.out.println(calendar.get(Calendar.DAY_OF_WEEK));// 5
        System.out.println(calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH)); // 4
        System.out.println(calendar.get(Calendar.WEEK_OF_MONTH)); // 4
        System.out.println(calendar.get(Calendar.WEEK_OF_YEAR)); // 34

        System.out.println(calendar.get(Calendar.HOUR_OF_DAY)); // 11
        System.out.println(calendar.get(Calendar.AM_PM));// 0
        System.out.println(calendar.get(Calendar.HOUR));// 11
        System.out.println(calendar.get(Calendar.MINUTE)); // 25
        System.out.println(calendar.get(Calendar.SECOND)); // 11
        System.out.println(calendar.get(Calendar.MILLISECOND)); // 252

        // 设置字段值
//        calendar.set(Calendar.MONTH, 5);
        calendar.set(Calendar.DAY_OF_MONTH, 32);

//        calendar.clear();
        System.out.println(calendar.getTime());

//        calendar.add(Calendar.HOUR_OF_DAY, 7);
//
//        System.out.println(calendar.getTime());

    }
}
